package com.alibaba.dingtalk.openapi.message;

import java.util.List;

/** 
  { 
    "message_url": "http://dingtalk.com", 
    "head": {
        "bgcolor": "FFCC0000"
    }, 
    "body": {
        "title": "标题", 
        "form": [
            {
                "key": "姓名", 
                "value": "张三"
            }, 
            {
                "key": "年龄", 
                "value": "30"
            }
        ], 
        "rich": {
            "num": "15.6", 
            "unit": "元"
        }, 
        "content": "大段文本", 
        "image": "@lADOAAGXIszazQKA", 
        "file_count": "3", 
        "author": "李四"
    }
 * @author dingtalk
 */
public class OAMessage extends AbstractMessage {

	/**
	 * 客户端点击消息时跳转到的H5地址
	 */
	public String message_url;
	/**
	 * PC端点击消息时跳转到的H5地址
	 */
	public String pc_message_url;

	public Head head;

	public Body body;
	
	public OAMessage() {
		this.head = new Head();
		this.head.bgcolor = "ffff943e";
		this.head.text = "销帮帮CRM";
	}

	@Override
	public String type() {
		return "oa";
	}
	
	public static class Head {
		/**
		 * 消息头部的背景颜色。长度限制为8个英文字符，其中前2为表示透明度，后6位表示颜色值。不要添加0x
		 */
		public String bgcolor;
		/**
		 * 消息的头部标题
		 */
		public String text;
	}
	
	public static class Body {
		/**
		 * 消息体的标题
		 */
		public String title;
		/**
		 * 消息体的表单，最多显示6个，超过会被隐藏
		 */
		public List<Form> form;
		/**
		 * 单行富文本信息
		 */
		public Rich rich;
		/**
		 * 消息体的内容，最多显示3行
		 */
		public String content;
		/**
		 * 消息体中的图片media_id
		 */
		public String image;
		/**
		 * 自定义的附件数目。此数字仅供显示，钉钉不作验证
		 */
		public String file_found;
		/**
		 * 自定义的作者名字
		 */
		public String author;
		
		public static class Form {
			/**
			 * 消息体的关键字
			 */
			public String key;
			/**
			 * 消息体的关键字对应的值
			 */
			public String value;

			public Form() {
			}

			public Form(String key, String value) {
				this.key = key;
				this.value = value;
			}
		}
		
		public static class Rich {
			/**
			 * 单行富文本信息的数目
			 */
			public String num;
			/**
			 * 单行富文本信息的单位
			 */
			public String unit;

			public Rich() {
			}

			public Rich(String num, String unit) {
				this.num = num;
				this.unit = unit;
			}
		}
	}
}
